home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / bcfamily / source / dosvect.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-12  |  2.2 KB  |  109 lines

  1. //
  2. //      *******************************************************************
  3. //        JdeBP C++ Library Routines          General Public Licence v1.00
  4. //            Copyright (c) 1991,1992     Jonathan de Boyne Pollard
  5. //      *******************************************************************
  6. //
  7. // Part of FamAPI.LIB
  8. //
  9.  
  10. #include "famapi.h"
  11. #include "dosdos.h"
  12.  
  13. static int Saved = 0 ;
  14.  
  15. static void interrupt (far *Int0Vect) () = NULL ;
  16. static void interrupt (far *Int4Vect) () = NULL ;
  17. static void interrupt (far *Int5Vect) () = NULL ;
  18. static void interrupt (far *Int6Vect) () = NULL ;
  19. static void interrupt (far *Int7Vect) () = NULL ;
  20. static void interrupt (far *Int10Vect) () = NULL ;
  21.  
  22. //
  23. //    Set a vector
  24. //
  25. void _APICALL
  26. DosDosSetVect ( USHORT VectNum,
  27.                 void interrupt (far *VecFN) () )
  28. {
  29.     asm push ds ;
  30.     _DX = FP_OFF(VecFN) ;
  31.     _DS = FP_SEG(VecFN) ;
  32.     _AX = VectNum ;
  33.     _AH = 0x25 ;
  34.     Dos3Call() ;
  35.     asm pop ds ;
  36. }
  37.  
  38. //
  39. //    Set a vector
  40. //
  41. void _APICALL
  42. DosDosGetVect ( USHORT VectNum,
  43.                 void interrupt (far * far *PtrVecFN) () )
  44. {
  45.     asm push ds ;
  46.     _BX = FP_OFF(PtrVecFN) ;
  47.     _ES = FP_SEG(PtrVecFN) ;
  48.     _AL = VectNum ;
  49.     _AH = 0x35 ;
  50.     Dos3Call() ;
  51.     asm pop ds ;
  52. }
  53.  
  54. //
  55. //    Save vectors
  56. //
  57. USHORT _APICALL
  58. DosDosSaveVectors    ( void )
  59. {
  60.     if (!Saved) {
  61.         asm push ds ;
  62.         _BX = FP_OFF(&Int0Vect) ;
  63.         _ES = FP_SEG(&Int0Vect) ;
  64.         _AX = 0x3500 ;
  65.         Dos3Call() ;
  66.         _BX = FP_OFF(&Int4Vect) ;
  67.         _ES = FP_SEG(&Int4Vect) ;
  68.         _AX = 0x3504 ;
  69.         Dos3Call() ;
  70.         _BX = FP_OFF(&Int5Vect) ;
  71.         _ES = FP_SEG(&Int5Vect) ;
  72.         _AX = 0x3505 ;
  73.         Dos3Call() ;
  74.         _BX = FP_OFF(&Int6Vect) ;
  75.         _ES = FP_SEG(&Int6Vect) ;
  76.         _AX = 0x3506 ;
  77.         Dos3Call() ;
  78.         _BX = FP_OFF(&Int7Vect) ;
  79.         _ES = FP_SEG(&Int7Vect) ;
  80.         _AX = 0x3507 ;
  81.         Dos3Call() ;
  82.         _BX = FP_OFF(&Int10Vect) ;
  83.         _ES = FP_SEG(&Int10Vect) ;
  84.         _AX = 0x3510 ;
  85.         Dos3Call() ;
  86.         asm pop ds ;
  87.         Saved = 1 ;
  88.     }
  89.     return NO_ERROR ;
  90. }
  91.  
  92. //
  93. //    Restore vectors
  94. //
  95. USHORT _APICALL
  96. DosDosRestoreVectors    ( void )
  97. {
  98.     if (Saved) {
  99.         DosDosSetVect (0x00, Int0Vect) ;
  100.         DosDosSetVect (0x04, Int4Vect) ;
  101.         DosDosSetVect (0x05, Int5Vect) ;
  102.         DosDosSetVect (0x06, Int6Vect) ;
  103.         DosDosSetVect (0x07, Int7Vect) ;
  104.         DosDosSetVect (0x10, Int10Vect) ;
  105.         Saved = 0 ;
  106.     }
  107.     return NO_ERROR ;
  108. }
  109.